public class Test {
    public static void main(String[] args) {
        //初始化所用数组
        int[]array={23,34,12,5,6,8,2,89};

        //堆的初始化
        MyPriorityQueue myPriorityQueueMax=new MyPriorityQueue();
        myPriorityQueueMax.init(array);

        //创建大根堆
        myPriorityQueueMax.createMaxHeap();
        myPriorityQueueMax.display();
        System.out.println("********************************");

        //向大根堆中添加元素
        myPriorityQueueMax.maxOffer(50);
        myPriorityQueueMax.display();
        System.out.println("********************************");

        //删除大根堆中的元素
        System.out.println("队头元素为:"+myPriorityQueueMax.maxPoll());
        myPriorityQueueMax.display();
        System.out.println("********************************");

        //获取大根堆的队头元素
        System.out.println("队头元素为:"+myPriorityQueueMax.peek());
        System.out.println("********************************");

        //堆的初始化
        MyPriorityQueue myPriorityQueueMin=new MyPriorityQueue();
        myPriorityQueueMin.init(array);

        //创建小根堆
        myPriorityQueueMin.createMinHeap();
        myPriorityQueueMin.display();
        System.out.println("********************************");

        //向小根堆中添加元素
        myPriorityQueueMin.minOffer(50);
        myPriorityQueueMin.display();
        System.out.println("********************************");

        //删除小根堆中的元素
        System.out.println("队头元素为:"+myPriorityQueueMin.minPoll());
        myPriorityQueueMin.display();
        System.out.println("********************************");

        //获取大根堆的队头元素
        System.out.println("队头元素为:"+myPriorityQueueMin.peek());
    }
}
